import ruleOpt from '@/biz/option/rule.js'
import templateMgr from '@/biz/bonus/template.js'

let _this = null

function rules() {
  console.log(123123)
  return _this.info.auditResultFlag == '2' ? [
    ruleOpt.required('请填写审批内容')
  ] : [{ required: false, message: '', }]
}

function options(vm, flag) {
  _this = vm
  let opt = [
    [{
      title: '审批结果',
      key: 'auditResultFlag',
      placeholder: '请选择',
      select: {
        options: [
          { key: '1', value: '通过' },
          { key: '2', value: '不通过' },
        ]
      },
      associationRules: ['auditReason'],
      change: () => {
        opt[1][0].rules = rules()
        _this.update()
      },
      rules: [
        ruleOpt.required('请选择审批结果'),
      ]
    }],
    [{
      title: '审批内容',
      key: 'auditReason',
      input: {
        type: 'textarea',
        maxlength: 50,
        autosize: {
          minRows: 4
        }
      },
      rules: rules()
    }]
  ]
  return opt
}

export default {
  options
}